package com.hhkj.admin.order.model.res;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.hhkj.admin.order.common.cont.OrderConst;
import com.hhkj.admin.order.common.cont.OrderRefundConst;
import com.hhkj.admin.order.model.dopo.OrderPo;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
public class OrderRes extends OrderPo {

    /** 商家名称以及编号 **/
    @Excel(name = "商家名称", orderNum = "1", width = 20)
    private String sale;

    /** 订单来源 **/
    @Excel(name = "订单来源", orderNum = "3", width = 20)
    private String sourceType;

    /** 订单状态 **/
    @Excel(name = "订单状态", orderNum = "5", width = 20)
    private String status;

    /** 订单状态 **/
    @Excel(name = "退款状态", orderNum = "6", width = 20)
    private String refundStatus;

    /** 支付方式 **/
    @Excel(name = "支付方式", orderNum = "7", width = 20)
    private String payMethod;

    /** 销售名称以及编号 **/
    @Excel(name = "所属销售", orderNum = "9", width = 20)
    private String saleRoot;

    @Excel(name = "创建时间", orderNum = "10", width = 20, format = "yyyy-MM-dd HH:mm")
    private Date createTimeForExcel;

    /** 退款金额 **/
    private BigDecimal refundPrice;

    public BigDecimal getRefundPrice() {
        return getPayPrice().subtract(getFinalPrice());
    }

    public String getPayMethod() {
        if (StringUtils.isNotBlank(getPayMethodCode())) {
            return OrderConst.PayMethodEnum.getNameByCode(getPayMethodCode());
        }
        return "";
    }

    public String getRefundStatus() {
        return OrderRefundConst.StatusEnum.getNameByCode(getRefundStatusCode());
    }

    public String getStatus() {
        return OrderConst.StatusEnum.getByCode(getStatusCode()).getName();
    }

    public String getSourceType() {
        return OrderConst.SourceTypeCode.getNameByCode(getSourceTypeCode());
    }

    public String getSale() {
        return getSaleName() + "(" + getSaleNum() + ")";
    }

    public String getSaleRoot() {
        return getSaleRootName() + "(" + getSaleRootNum() + ")";
    }

    public Date getCreateTimeForExcel() {
        return super.getCreateTime();
    }
}
